package game;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.util.ArrayList;
import java.util.Hashtable;

import javax.swing.JFrame;

public class Board extends JFrame
{

	public Hashtable<String, Square> squares = new Hashtable<String, Square>();

	public Board()
	{
		super("Chess!");
		// make chess squares
		for (int i = 0; i < 9; i++)
		{
			for (int j = 0; j < 9; j++)
			{
				squares.put(i + "," + j, new Square(i, j));
				if ((i + j) % 2 == 0)
				{
					squares.get(i + "," + j).setC(Color.white);
				}
				getContentPane().add(squares.get(i + "," + j));
			}
		}
		// add neighbours for easy pathfinding
		for (Square s : squares.values())
		{
			s.setNorth(squares.get(s.getRow() - 1 + "," + s.getColumn()));
			s.setSouth(squares.get(s.getRow() + 1 + "," + s.getColumn()));
			s.setEast(squares.get(s.getRow() + "," + (s.getColumn() + 1)));
			s.setWest(squares.get(s.getRow() + "," + (s.getColumn() - 1)));
		}

		getContentPane().setVisible(true);
		getContentPane().setLayout(new GridLayout(9, 9));
		
		setSize(810,810);
	    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
	    setLocation((dim.width-getWidth())/2, (dim.height-getHeight())/2);
	    setVisible(true);
	}
}
